import request from "@/utils/http";

/**
 * 物品的详细查询
 * @returns {*}
 */
export function getOne() {
  return request({
    url: "/article/getOne",
  });
}

/**
 * 按分类查询
 * @param {*} CategoryId
 */
export function getCategoryById(categoryId) {
  return request({
    url: "/article/getCategoryById",
    params: { categoryId: categoryId },
  });
}

/**
 *主要物品的查询
 * @returns
 */
export function homepageData() {
  return request({
    url: "/article/homepageData",
  });
}

/**
 * 根据物品名搜索
 * @param {*} name
 */
export function nameSearch(name) {
  return request({
    url: "/article/nameSearch",
    params: name,
  });
}

/**
 * 上架商品
 * @param {*} article 商品信息
 * @param {*} file 图片
 * @returns
 */
export function add(article, file) {
  return request({
    headers: {
      "Content-Type": "multipart/form-data",
    },
    url: "/article/add",
    params: article,
    data: file,
  });
}

/**
 * 下架商品
 * @param {*} id
 * @returns
 */
export function remove(id) {
  return request({
    url: "/article/remove",
    params: id,
  });
}
